package com.adgox.tiantianbiting.mine.login;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.adgox.tiantianbiting.R;
import com.adgox.tiantianbiting.TtbtApplication;
import com.tencent.mm.opensdk.modelmsg.SendAuth;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.tv_login)
    public void onLoginClicked() {
        if (!TtbtApplication.wxapi.isWXAppInstalled()) {
            Toast.makeText(this, "请先安装微信客户端", Toast.LENGTH_SHORT).show();
            return;
        }

        SendAuth.Req req = new SendAuth.Req();
        req.scope = "snsapi_userinfo";
        req.state = System.currentTimeMillis() + "ttbt";
        TtbtApplication.wxapi.sendReq(req);
        finish();
    }

    @OnClick(R.id.img_finish)
    public void onFinishClicked() {
        finish();
    }
}
